
//
//  UIBarButtonItem+Extensions.swift
//  ZWWEIBO
//
//  Created by xzw on 2017/12/19.
//  Copyright © 2017年 xzw. All rights reserved.
//

import UIKit


extension UIBarButtonItem{
    
    /// 创建UIBarButtonItem
    ///
    /// - Parameters:
    ///   - title: title
    ///   - fonsize: fonsize,默认16
    ///   - target: target
    ///   - action: action
    ///   -isBackButton : 是否是返回按钮
    convenience init(title:String,fonsize:CGFloat = 16,target:AnyObject?,action:Selector,isBackButton : Bool = false){
        
        let btn:UIButton = UIButton.cz_textButton(title, fontSize: fonsize, normalColor:UIColor.darkGray , highlightedColor: UIColor.orange)
        
        if isBackButton
        {
            let imageName = "navigationbar_back_withtext"
            btn.setImage(UIImage(named:imageName), for: .normal)
            btn.setImage(UIImage(named:imageName+"_highlighted"), for: .highlighted)
        }
        
        btn.addTarget(target, action:action, for: .touchUpInside)
        
        //self.init 实例化 UIBarButtonItem
        self.init(customView: btn)
    }
    
}
